# 暴力法
def sumTwo(nums, target):
    result = []
    for i in (0, len(nums)):
        for j in (i + 1, len(nums)):
            sum = nums[i] + nums[j]
            if sum == target:
                result.append(i)
                result.append(j)
                return result
    return result


# 哈希表法
def twoSum(nums, target):
    hasmap = {}
    for i, num in enumerate(nums):
        if target - num in hasmap:
             return [hasmap[target - num], i]
        hasmap[num] = i


def main():
    nums = [2,7,11,15]
    target = 9
    # 暴力法
    resultb = sumTwo(nums, target)
    print(resultb)
    # hasmap
    resulth = twoSum(nums, target)
    print(resulth)


if __name__ == '__main__':
    main()
        